package com.example;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class StudentGradeDetailsController implements StudentSubController {

    @FXML
    private Label courseNameLabel;
    @FXML
    private Label scoreLabel;
    @FXML
    private Label semesterLabel;
    @FXML
    private Label courseTypeLabel;
    @FXML
    private Label examTimeLabel;
    @FXML
    private Label teacherNameLabel;
    @FXML
    private Button backButton;

    private Stage primaryStage;
    private StudentController studentController;

    @Override
    public void setPrimaryStage(Stage primaryStage) {
        this.primaryStage = primaryStage;
    }

    @Override
    public void setStudentController(StudentController studentController) {
        this.studentController = studentController;
    }

    public void setGrade(Grade grade) {
        if (grade != null) {
            courseNameLabel.setText(grade.getCourseName());
            scoreLabel.setText(String.valueOf(grade.getScore()));
            semesterLabel.setText(grade.getSemester());
            courseTypeLabel.setText(grade.getCourseType());
            examTimeLabel.setText(grade.getExamTime());
            teacherNameLabel.setText(grade.getTeacherName());
        }
    }

    @FXML
    private void handleBack() {
        if (studentController != null) {
            // 返回到成绩列表界面
            studentController.showStudentViewGradesView(); // 假设StudentController有一个方法来显示成绩列表
        } else {
            System.err.println("studentController is null in StudentGradeDetailsController.");
        }
    }
} 